package com.twohand.admin.Util;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

@Data
public class PageResponse<T> {
    Integer pages;
    long total;
    Integer pageNum;
    Integer pageSize;
    Object list;
    public PageResponse(PageInfo<T> pageInfo, List<T> data){
        this.pages = pageInfo.getPages();
        this.total = pageInfo.getTotal();
        this.pageNum = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.list = data;
        PageHelper.clearPage();
    }
    public PageResponse(PageInfo<T> pageInfo, Object data){
        this.pages = pageInfo.getPages();
        this.total = pageInfo.getTotal();
        this.pageNum = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.list = data;
        PageHelper.clearPage();
    }

    public PageResponse() {

    }
}
